<?php
class Service_Comment
{
    protected $_commentMapper;
    
    protected $_postMapper;
    
    public function __construct($commentMapper = null, $postMapper = null)
    {
        if($commentMapper===null){
            $this->setCommentMapper(new Model_CommentsMapper());
        } else {
            $this->setCommentMapper($commentMapper);
        }
        
        if($postMapper === null){
            $this->setPostMapper(new Model_PostsMapper());
        } else {
            $this->setPostMapper($postMapper);
        }
    }
    
    public static function getInstance()
    {
        return new self();
    }
    
    public function setCommentMapper($commentMapper)
    {
        $this->_commentMapper = $commentMapper;
    }
    
    public function getCommentMapper()
    {
        return $this->_commentMapper;
    }
    
    public function setPostMapper($postMapper)
    {
        $this->_postMapper = $postMapper;
    }
    
    public function getPostMapper()
    {
        return $this->_postMapper;
    }
    
    public function saveComment($comment)
    {
       return $this->_commentMapper->save($comment);
    }
    
    public function findComment($id)
    {
        return $this->_commentMapper->find($id);
    }
    
    public function deleteComment($comment)
    {
        $this->_commentMapper->delete($comment);
    }
}